package com.elinkway.infinitemovies.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.le123.ysdq.R;

public class TipsTxtAdapter extends MyBaseAdapter {

	private String[] tipsStrings;
	private boolean isRank;

	private class KeywordHolder {
		TextView tipRankTv;
		TextView tipNameTv;
	}

	public TipsTxtAdapter(Context context, String[] tipsStrings, boolean isRank) {
		super(context);
		this.tipsStrings = tipsStrings;
		this.isRank = isRank;
	}

	@Override
	public int getCount() {
		return tipsStrings.length;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup arg2) {
		KeywordHolder holder = new KeywordHolder();
		if(convertView==null){
			convertView=inflater.inflate(R.layout.tips_txt_item, null);
			holder.tipRankTv = (TextView) convertView.findViewById(R.id.tip_rank_tv);
			holder.tipNameTv = (TextView) convertView.findViewById(R.id.tip_name_tv);
			convertView.setTag(holder);
		}
		else{
			holder=(KeywordHolder) convertView.getTag();
		}
		if(isRank){
			holder.tipRankTv.setText(position + 1 +"");
			holder.tipRankTv.setVisibility(View.VISIBLE);
		}else{
			holder.tipRankTv.setVisibility(View.GONE);
			holder.tipNameTv.setPadding(0,0,0,0);
		}
		holder.tipNameTv.setText(tipsStrings[position]);

		return convertView;
	}

}
